import Coordinates from "./Coordinates";

export default class ResManager {

    static autoTestLevels = false;//TODO

    static currentLevelIndex = 0;

    static levelResArray = [
        'A004', 'A005', 'A010', 'A011', 'A012',
        'A013', 'A014', 'A016', 'A018', 'A019',
        'A021', 'A022', 'A023', 'A026', 'A027',
        'A028', 'A029', 'A030', 'A031', 'A033',
        'A034', 'A036', 'A037', 'A038', 'A040',
        'A041', 'A044', 'A045', 'A048',
        'A049', 'A050', 'A051', 'A053', 'A060',
        'A061', 'A062', 'A063', 'A064', 'A065',
        'A066', 'A067', 'A068', 'A069', 'A070',
        'A071', 'A072', 'A073', 'A074', 'A075',
        'A076', 'A077', 'A078', 'A079', 'A080',
        'A081', 'A082', 'A083', 'A084', 'A085', 
        'A086', 'A087', 'A088', 'A089', 'A090', 
        'A091', 'A092',
        'A055', 'A056', 'ani001',
        'ani002', 'ani003',
        'food001', 'food002', 'food003', 'food004', 'food005',
        'food006', 'food007', 'food008', 'food009', 'food010',
        'food011', 'food012', 'food013', 'food014', 'food015',
        'food016', 'food017', 'food018', 'food019', 'm063',
        'm080', 'm118', 'm169', 'm267'
    ]
    //'A003', 'A006', 'A020','A035',  'A042', 'A052', 
    //'m021','m024','m043', 'm087','m109','m171','m210','m232','m272','m283','m285', 
    //'m098','m095','m121','m129','m239','m253',   'm019', 'm027', 'm038', 'm047','m050',
    //'m051','m071','m172','m209','m212','m228','m231','m276','m289',
    //'m046', 'm045', 'm059', 'm110','m128','m132','m136','m179','m255','m258',
    static getLevelResArray() {
        return this.levelResArray;
    }

    /**
     * 关卡资源名字
     */
    static getLevelResNameByIndex(index: number) {
        return this.getLevelResArray()[index];
    }

    static getNextLevel() {
        if (this.currentLevelIndex == this.levelResArray.length - 1)
            return 0;
        return this.currentLevelIndex + 1;
    }

    static getDiffCount() {
        return 5;
    }

    static getDiffConfigRect(index: number): cc.Rect {
        let resName = ResManager.getLevelResNameByIndex(ResManager.currentLevelIndex);
        let config = Coordinates.config[resName]
        let key = resName + "_" + index;
        let cfg = config[key];
        if (cfg == null) {
            console.error(`ResManager.getDiffConfigRect(${index}) error, resName:${resName}`);
            return cc.rect(0, 0, 1, 1);
        }
        return cc.rect(cfg.x, cfg.y, cfg.w, cfg.h);
    }

    static getDiffConfigCoordinate(index: number): cc.Vec2 {
        return this.getDiffConfigRect(index).origin;
    }

}
